
#include "../ui.h"
#include "../app_includes.h"

static lv_obj_t *ui_screen;
static lv_obj_t *ui_LabelScreen;
static lv_obj_t *ui_Button;
static lv_obj_t *ui_LabelBtn;

static void btn_homeback_click(lv_event_t *e);

//状态栏入口
lv_obj_t *lv_status_bar_load(void)
{
    //ui_screen = lv_screen_create(ui_main_screen.status_bar,lv_pct(100), lv_pct(100));
    ui_screen = ui_main_screen.status_bar;
/*    ui_LabelScreen = lv_label_create(ui_screen);
    lv_obj_set_align(ui_LabelScreen, LV_ALIGN_CENTER);
    lv_label_set_text(ui_LabelScreen, "home");
    lv_obj_set_style_text_color(ui_LabelScreen, lv_color_hex(0xffffff), LV_PART_MAIN | LV_STATE_DEFAULT);
*/
    ui_Button = lv_btn_create(ui_screen);
    lv_obj_set_style_opa(ui_Button,LV_OPA_100, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_size(ui_Button, 80, 30);
    lv_obj_align(ui_Button, LV_ALIGN_LEFT_MID,10,0);
    lv_obj_set_style_bg_color(ui_Button, lv_color_hex(0x343434), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_add_event_cb(ui_Button, btn_homeback_click, LV_EVENT_CLICKED, NULL);
    lv_obj_set_style_radius(ui_Button, 10, LV_PART_MAIN| LV_STATE_DEFAULT);

    ui_LabelBtn = lv_label_create(ui_Button);
    lv_label_set_text(ui_LabelBtn, LV_SYMBOL_HOME " back");
    lv_obj_align_to(ui_LabelBtn, ui_Button, LV_ALIGN_CENTER, 0, 0);
    lv_obj_set_style_text_color(ui_LabelBtn, lv_color_hex(0xffffff), LV_PART_MAIN | LV_STATE_DEFAULT);

    return ui_screen;
}

static void btn_homeback_click(lv_event_t *e)
{
    if(ui_main_screen.app_close!=NULL) {
        ui_main_screen.app_close();
        ui_main_screen.app_close = NULL;
    }
    lv_obj_del(ui_main_screen.current_desktop);
    ui_main_screen.current_desktop = lv_homepage_load();
}
